<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    window.addEventListener('online',function(){
       alert('网络连接已建立！');
    });

    window.addEventListener('offline',function(){
        alert('网络连接已断开！');
    })
</script>
</body>
</html>